package com.jxin.mall.weixin.service.api;

import com.jxin.mall.entity.entity.GlobalRsp;
import com.jxin.mall.weixin.service.entity.dto.rsp.WxUserRspDTO;
import io.swagger.annotations.*;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 微信授权服务接口
 * @author  蔡佳新
 * @version 1.0
 * @since   jdk 1.8
 */
@Api(tags = "微信授权服务接口")
@RequestMapping("/access")
public interface WxAccessService {
    /**
     * 获取授权url
     * @param  backUrl 回调地址
     * @return 全局响应参数
     * @author 蔡佳新
     */
    @ApiOperation(value = "获取授权地址", response = String.class)
    @GetMapping(value = "/getAccessUrl", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiResponses({@ApiResponse(code=200,message="响应请求成功"),
                   @ApiResponse(code=500,message="系统错误")})
    GlobalRsp<String> getAccessUrl(
            @ApiParam(value = "回调地址", required = true) @RequestParam("backUrl")String backUrl);

    /**
     * 获取微信用户信息
     * @param  accessToken 微信授权令牌
     * @return 全局响应参数
     * @author 蔡佳新
     */
    @ApiOperation(value = "获取微信用户信息", response = WxUserRspDTO.class)
    @GetMapping(value = "/getWxUser", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiResponses({@ApiResponse(code=200,message="响应请求成功"),
                   @ApiResponse(code=500,message="系统错误")})
    GlobalRsp<WxUserRspDTO> getWxUser(
            @ApiParam(value = "微信授权令牌", required = true) @RequestParam("accessToken")String accessToken);
}
